package br.ufpe.cin.mac.demo.StringServer;

import br.ufpe.cin.mac.middleware.Middleware;
import br.ufpe.cin.mac.nameService.NameServiceClient;
import br.ufpe.cin.mac.util.Proxy;

public class StringClient {
	public static void main(String obf[]) {

		// Middleware mid = new Middleware("localhost", "Config.xml");

		// Proxy m = new Proxy(new StringClient(), StringServer.class, mid);

		NameServiceClient ns = new NameServiceClient("127.0.0.1");
		IStringServer proxy = (IStringServer) ns.lookup(IStringServer.class
				.getName());

		/*
		 * Middleware mid = new Middleware("localhost", "Config.xml");
		 * 
		 * Proxy m = new Proxy(new StringClient(), StringServer.class, mid);
		 * 
		 * IStringServer proxy = (IStringServer) java.lang.reflect.Proxy
		 * .newProxyInstance(Thread.currentThread() .getContextClassLoader(),
		 * new Class[] { IStringServer.class }, (Proxy) m);
		 */

		System.out.println(proxy.getName("Primeiro Teste"));
		try {
			Thread.sleep(20000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println(proxy.getName("Segundo Teste"));
		try {
			Thread.sleep(10000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println(proxy.getName("Terceiro Teste"));
		try {
			Thread.sleep(10000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println(proxy.getName("Quarto Teste"));
		try {
			Thread.sleep(10000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println(proxy.getName("Quinto Teste"));

		// System.exit(0);
	}
}
